<script setup lang="js">
import { ref, onMounted, onUnmounted } from 'vue'

const link = ref('https://github.com/guocaoyi/create-chrome-ext')

const getTime = () => {
  const date = new Date()
  const hour = String(date.getHours()).padStart(2, '0')
  const minute = String(date.getMinutes()).padStart(2, '0')
  return `${hour}:${minute}`
}

let time = ref(getTime())
let intervalor = null

onMounted(() => {
  intervalor = setInterval(() => {
    time.value = getTime()
  }, 1000)
})

onUnmounted(() => {
  clearInterval(intervalor)
})
</script>

<template>
  <section>
    <span></span>
    <h1>{{ time }}</h1>
    <a :href="link" target="_blank"> generated by create-chrome-ext </a>
  </section>
</template>

<style>
:root {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    'Open Sans',
    'Helvetica Neue',
    sans-serif;

  color-scheme: light dark;
  box-sizing: border-box;
}

body {
  min-width: 20rem;
  margin: 0;
}

section::before {
  content: '';
  position: fixed;
  z-index: -1;
  width: 100vw;
  height: 100vh;
  background-image: url('https://source.unsplash.com/random');
  background-size: cover;
  filter: blur(10px);
}

section {
  width: 100vw;
  height: 100vh;

  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

h1 {
  color: #42b983;
  text-transform: uppercase;
  font-size: 6rem;
  margin: 2rem auto;
}

a {
  font-size: 0.5rem;
  margin: 0.5rem;
  color: #cccccc;
  text-decoration: none;
}
</style>
